package cl.scene.badseeds;

import org.eclipse.jetty.util.MultiMap;

import java.io.UnsupportedEncodingException;

/**
 * Created by IntelliJ IDEA.
 * User: Patricio
 * Date: 27-11-2010
 * Time: 10:42:11 PM
 */
public class AnnounceRequest {
    private String passKey;
    private byte[] infoHash;
    private byte[] peerId;
    private String ip;
    private int port;
    private long uploaded;
    private long downloaded;
    private long left;
    private String event;
    private int numwant;
    private boolean partial;

    public AnnounceRequest(MultiMap m) throws UnsupportedEncodingException {

        infoHash = m.getString("info_hash").getBytes("UTF-8");
        peerId = m.getString("peer_id").getBytes("UTF-8");
        ip = m.getString("ip");
        port = Integer.parseInt(m.getString("port"));
        uploaded = Long.parseLong(m.getString("uploaded"));
        downloaded = Long.parseLong(m.getString("downloaded"));
        left = Long.parseLong(m.getString("left"));
        event = m.getString("event");
        numwant = m.getString("numwant") == null ? 200 : Integer.parseInt(m.getString("numwant"));

    }

    public String getPassKey() {
        return passKey;
    }

    public void setPassKey(String passKey) {
        this.passKey = passKey;
    }

    public byte[] getInfoHash() {
        return infoHash;
    }

    public void setInfoHash(byte[] infoHash) {
        this.infoHash = infoHash;
    }

    public byte[] getPeerId() {
        return peerId;
    }

    public void setPeerId(byte[] peerId) {
        this.peerId = peerId;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public long getUploaded() {
        return uploaded;
    }

    public void setUploaded(long uploaded) {
        this.uploaded = uploaded;
    }

    public long getDownloaded() {
        return downloaded;
    }

    public void setDownloaded(long downloaded) {
        this.downloaded = downloaded;
    }

    public long getLeft() {
        return left;
    }

    public void setLeft(long left) {
        this.left = left;
    }

    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    public int getNumwant() {
        return numwant;
    }

    public void setNumwant(int numwant) {
        this.numwant = numwant;
    }

    public boolean isPartial() {
        return partial;
    }

    public void setPartial(boolean partial) {
        this.partial = partial;
    }
}
